home *** CD-ROM | disk | FTP | other *** search
/ BMUG Revelations / BMUG Revelations.toast / Programming / Programming Languages / Harvest C / MPW Int & Lib / Interfaces / StandardFile.h < prev    next >
Text File  |  1991-04-17  |  8KB  |  260 lines

  1. /************************************************************
  2.  
  3. Created: Sunday, January 6, 1991 at 10:06 PM
  4.     StandardFile.h
  5.     C Interface to the Macintosh Libraries
  6.  
  7.  
  8.         Copyright Apple Computer, Inc.    1990
  9.         All rights reserved
  10.  
  11. ************************************************************/
  12.  
  13.  
  14. #ifndef __STANDARDFILE__
  15. #define __STANDARDFILE__
  16.  
  17. #ifndef __TYPES__
  18. #include <Types.h>
  19. #endif
  20.  
  21. #ifndef __DIALOGS__
  22. #include <Dialogs.h>
  23. #endif
  24.  
  25. #ifndef __FILES__
  26. #include <Files.h>
  27. #endif
  28.  
  29.  
  30. enum {
  31.  
  32.  
  33. /* resource IDs and item offsets of pre-7.0 dialogs */
  34.     putDlgID = -3999,
  35.     putSave = 1,
  36.     putCancel = 2,
  37.     putEject = 5,
  38.     putDrive = 6,
  39.     putName = 7,
  40.  
  41.     getDlgID = -4000,
  42.     getOpen = 1,
  43.     getCancel = 3,
  44.     getEject = 5,
  45.     getDrive = 6,
  46.     getNmList = 7,
  47.     getScroll = 8,
  48.  
  49. /* resource IDs and item offsets of 7.0 dialogs */
  50.     sfPutDialogID = -6043,
  51.     sfGetDialogID = -6042,
  52.     sfItemOpenButton = 1,
  53.     sfItemCancelButton = 2,
  54.     sfItemBalloonHelp = 3,
  55.     sfItemVolumeUser = 4,
  56.     sfItemEjectButton = 5
  57. };
  58. enum {
  59.     sfItemDesktopButton = 6,
  60.     sfItemFileListUser = 7,
  61.     sfItemPopUpMenuUser = 8,
  62.     sfItemDividerLinePict = 9,
  63.     sfItemFileNameTextEdit = 10,
  64.     sfItemPromptStaticText = 11,
  65.     sfItemNewFolderUser = 12,
  66.  
  67.  
  68. /* pseudo-item hits for use in DlgHook */
  69.     sfHookFirstCall = -1,
  70.     sfHookCharOffset = 0x1000,
  71.     sfHookNullEvent = 100,
  72.     sfHookRebuildList = 101,
  73.     sfHookFolderPopUp = 102,
  74.     sfHookOpenFolder = 103,
  75.  
  76.  
  77. /* the following are only in system 7.0+ */
  78.     sfHookOpenAlias = 104,
  79.     sfHookGoToDesktop = 105,
  80.     sfHookGoToAliasTarget = 106,
  81.     sfHookGoToParent = 107,
  82.     sfHookGoToNextDrive = 108,
  83.     sfHookGoToPrevDrive = 109,
  84.     sfHookChangeSelection = 110
  85. };
  86. enum {
  87.     sfHookSetActiveOffset = 200,
  88.     sfHookLastCall = -2
  89.  
  90. /* the refcon field of the dialog record during a
  91.  modalfilter or dialoghook contains one of the following */
  92.  
  93. #define sfMainDialogRefCon 'stdf'
  94. #define sfNewFolderDialogRefCon 'nfdr'
  95. #define sfReplaceDialogRefCon 'rplc'
  96. #define sfStatWarnDialogRefCon 'stat'
  97. #define sfLockWarnDialogRefCon 'lock'
  98. #define sfErrorDialogRefCon 'err '
  99. };
  100.  
  101. struct SFReply {
  102.     Boolean good;
  103.     Boolean copy;
  104.     OSType fType;
  105.     short vRefNum;
  106.     short version;
  107.     Str63 fName;
  108. };
  109.  
  110. typedef struct SFReply SFReply;
  111.  
  112. struct StandardFileReply {
  113.     Boolean sfGood;
  114.     Boolean sfReplacing;
  115.     OSType sfType;
  116.     FSSpec sfFile;
  117.     ScriptCode sfScript;
  118.     short sfFlags;
  119.     Boolean sfIsFolder;
  120.     Boolean sfIsVolume;
  121.     long sfReserved1;
  122.     short sfReserved2;
  123. };
  124.  
  125. typedef struct StandardFileReply StandardFileReply;
  126.  
  127.  
  128. typedef pascal short (*DlgHookProcPtr)(short item, DialogPtr theDialog);
  129. typedef pascal Boolean (*FileFilterProcPtr)(ParmBlkPtr PB);
  130.  
  131. /* the following also include an extra parameter of "your data pointer" */
  132. typedef pascal short (*DlgHookYDProcPtr)(short item, DialogPtr theDialog, void *yourDataPtr);
  133. typedef pascal Boolean (*ModalFilterYDProcPtr)(DialogPtr theDialog, EventRecord *theEvent, short *itemHit, void *yourDataPtr);
  134. typedef pascal Boolean (*FileFilterYDProcPtr)(ParmBlkPtr PB, void *yourDataPtr);
  135. typedef pascal void (*ActivateYDProcPtr)(DialogPtr theDialog, short itemNo, Boolean activating, void *yourDataPtr);
  136.  
  137. typedef OSType SFTypeList[4];
  138.  
  139. #ifdef __cplusplus
  140. extern "C" {
  141. #endif
  142. pascal void SFPutFile(Point where,
  143.                       ConstStr255Param prompt,
  144.                       ConstStr255Param origName,
  145.                       DlgHookProcPtr dlgHook,
  146.                       SFReply *reply)
  147.     = {0x3F3C,0x0001,0xA9EA}; 
  148.  
  149. pascal void SFGetFile(Point where,
  150.                       ConstStr255Param prompt,
  151.                       FileFilterProcPtr fileFilter,
  152.                       short numTypes,
  153.                       SFTypeList typeList,
  154.                       DlgHookProcPtr dlgHook,
  155.                       SFReply *reply)
  156.     = {0x3F3C,0x0002,0xA9EA}; 
  157.  
  158. pascal void SFPPutFile(Point where,
  159.                        ConstStr255Param prompt,
  160.                        ConstStr255Param origName,
  161.                        DlgHookProcPtr dlgHook,
  162.                        SFReply *reply,
  163.                        short dlgID,
  164.                        ModalFilterProcPtr filterProc)
  165.     = {0x3F3C,0x0003,0xA9EA}; 
  166.  
  167. pascal void SFPGetFile(Point where,
  168.                        ConstStr255Param prompt,
  169.                        FileFilterProcPtr fileFilter,
  170.                        short numTypes,
  171.                        SFTypeList typeList,
  172.                        DlgHookProcPtr dlgHook,
  173.                        SFReply *reply,
  174.                        short dlgID,
  175.                        ModalFilterProcPtr filterProc)
  176.     = {0x3F3C,0x0004,0xA9EA}; 
  177.  
  178. pascal void StandardPutFile(ConstStr255Param prompt,
  179.                             ConstStr255Param defaultName,
  180.                             StandardFileReply *reply)
  181.     = {0x3F3C,0x0005,0xA9EA}; 
  182.  
  183. pascal void StandardGetFile(FileFilterProcPtr fileFilter,
  184.                             short numTypes,
  185.                             SFTypeList typeList,
  186.                             StandardFileReply *reply)
  187.     = {0x3F3C,0x0006,0xA9EA}; 
  188.  
  189. pascal void CustomPutFile(ConstStr255Param prompt,
  190.                           ConstStr255Param defaultName,
  191.                           StandardFileReply *reply,
  192.                           short dlgID,
  193.                           Point where,
  194.                           DlgHookYDProcPtr dlgHook,
  195.                           ModalFilterYDProcPtr filterProc,
  196.                           short *activeList,
  197.                           ActivateYDProcPtr activateProc,
  198.                           void *yourDataPtr)
  199.     = {0x3F3C,0x0007,0xA9EA}; 
  200.  
  201. pascal void CustomGetFile(FileFilterYDProcPtr fileFilter,
  202.                           short numTypes,
  203.                           SFTypeList typeList,
  204.                           StandardFileReply *reply,
  205.                           short dlgID,
  206.                           Point where,
  207.                           DlgHookYDProcPtr dlgHook,
  208.                           ModalFilterYDProcPtr filterProc,
  209.                           short *activeList,
  210.                           ActivateYDProcPtr activateProc,
  211.                           void *yourDataPtr)
  212.     = {0x3F3C,0x0008,0xA9EA}; 
  213.  
  214. void sfpputfile(Point *where,char *prompt,char *origName,DlgHookProcPtr dlgHook,
  215.     SFReply *reply,short dlgID,ModalFilterProcPtr filterProc); 
  216. void sfgetfile(Point *where,char *prompt,FileFilterProcPtr fileFilter,short numTypes,
  217.     SFTypeList typeList,DlgHookProcPtr dlgHook,SFReply *reply); 
  218. void sfpgetfile(Point *where,char *prompt,FileFilterProcPtr fileFilter,
  219.     short numTypes,SFTypeList typeList,DlgHookProcPtr dlgHook,SFReply *reply,
  220.     short dlgID,ModalFilterProcPtr filterProc); 
  221. void sfputfile(Point *where,char *prompt,char *origName,DlgHookProcPtr dlgHook,
  222.     SFReply *reply); 
  223.  
  224. /* 
  225.     
  226.         New StandardFile routine comments:
  227.     
  228.         activeList is pointer to array of integer (16-bits).
  229.         first integer is length of list.
  230.         following integers are possible activatable DITL items, in
  231.         the order that the tab key will cycle through.  The first
  232.         in the list is the item made active when dialog is first shown.
  233.     
  234.         activateProc is a pointer to a procedure like:
  235.     
  236.             PROCEDURE MyActivateProc(theDialog:     DialogPtr;
  237.                                      itemNo:        INTEGER;
  238.                                      activating:    BOOLEAN;
  239.                                      yourDataPtr:    Ptr);
  240.     
  241.         The activateProc is called with activating=FALSE on the itemNo
  242.         about to deactivate then with activating=TRUE on the itemNo
  243.         about to become the active item. (like activate event)
  244.     
  245.         yourDataPtr is a nice little extra that makes life easier without
  246.         globals.  CustomGetFile & CustomPPutFile when calling any of their
  247.         call back procedures, pushes the extra parameter of yourDataPtr on
  248.         the stack.
  249.     
  250.         In addition the filterProc in CustomGetFile & CustomPPutFile is called
  251.         before before SF does any mapping, instead of after.
  252. */
  253.  
  254.  
  255. #ifdef __cplusplus
  256. }
  257. #endif
  258.  
  259. #endif
  260.